﻿using IQIGame.Onigao.Framework;

namespace IQIGame.Onigao.Logic
{
    public class BattleTurnStartState: BattleBaseState
    {
        public BattleTurnStartState(BattlePlayController playController) : base(playController)
        {
        }

        public override EBattleState stateId => EBattleState.TurnStart;
        public override void OnInit()
        {
        }

        public override void OnEnter(EBattleState prevStateId)
        {
            if (this.mPlayCtrl.TryBattleEnd(out var nSuccessTeam))
            {
                this.mPlayCtrl.EndBattle(nSuccessTeam);
            }
            else if (this.mPlayCtrl.queueCtrl.TryNextTurn())
            {
                this.ChangeState(EBattleState.Turn);
            }
            else
            {
                this.ChangeState(EBattleState.RoundEnd);
            }
        }

        public override void OnExit()
        {
        }

        public override void Dispose()
        {
        }
    }
}